define(
	[],
	function() {
		return function(content, loading) {
			var token = localStorage.getItem("token");
			loading.hide();
			var jobDate = content.find("[name='jobDate']");
			jobDate.click(function() {
				var d = new Date();
				var d1 = new Date();
				d1.setMonth(d.getMonth() - 3);
				var d2 = new Date();
				d2.setMonth(d.getMonth() + 6);
				weui.datePicker({
					start: d1.format(),
					end: d2.format(),
					cron: '* * *',
					defaultValue: [d.getFullYear(), d.getMonth() + 1, d.getDate()],
					onChange: function(result) {
						jobDate.val(result[0].value + "-" + result[1].value + "-" + result[2].value);
					},
					onConfirm: function(result) {
						jobDate.val(result[0].value + "-" + result[1].value + "-" + result[2].value);
					}
				});
			});

			var form = content.find("form");

			loading = weui.loading("获取数据中");

			$.post(
				"job/get.do", {
					"token": token
				},
				function(data) {
					loading.hide();
					if(data.ok) {
						if(data.job != null) {
							$.each(data.job, function(name, value) {
								form.find("[name='" + name + "']").val(value);
							});
						}
					} else {
						weui.topTips(data.message);
					}
				}, "json"
			);

			form.submit(function(e) {
				loading = weui.loading("数据提交中");
				var ps = form.serializeArray();
				ps.push({
					name: "token",
					value: token
				});
				$.post(
					"job/save.do",
					ps,
					function(data) {
						loading.hide();
						if(data.ok) {
							weui.toast('保存成功', 1000);
						} else {
							weui.topTips(data.message);
						}
					}, "json"
				);

				return false;
			});

		}
	});